//
//  DiscTopReusableView.swift
//  WalkNovel
//
//  Created by Kevin on 2023/7/11.
//

import UIKit

class DiscTopReusableView: UICollectionReusableView {
    
    lazy var leftLabel: UILabel = {
        let label = UILabel()
        label.font = .wn_font(name: .bold, size: 18)
        label.textColor = .black
        return label
    }()
    
    lazy var viewBtn: UIButton = {
        let btn = UIButton(type: .custom)
        btn.setImage(UIImage(named: "library_arrow_pink"), for: .normal)
        btn.imageView?.contentMode = .scaleAspectFit
        btn.setTitle("看全部", for: .normal)
        btn.setTitleColor(.init(named: "red_FE95B4"), for: .normal)
        btn.titleLabel?.font = .wn_font(name: .bold, size: 12)
        btn.rx.tap.bind { [weak self] in
            self?.categoryClosure?()
        }.disposed(by: rx.disposeBag)
        return btn
    }()
            
    var showBooKLike: Bool? {
        didSet {
            leftLabel.text = "猜你喜歡"
            leftLabel.font = .wn_font(name: .bold, size: 14)
            leftLabel.textColor = .init(named: "gray_99999")
            viewBtn.isHidden = true
        }
    }
    
    var categoryClosure: ReturnClosure?

    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(leftLabel)
        addSubview(viewBtn)
        leftLabel.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(12)
        }
        viewBtn.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalTo(-12)
            make.height.equalTo(12)
        }
        viewBtn.layoutButton(style: .right, imageTitleSpace: 4)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
